package com.wms_backend.controller;

import com.wms_backend.dao.UserDao;
import com.wms_backend.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
    @Autowired
    private UserDao userDao;

    @Autowired
    private KafkaTemplate<String, Object> kafkaTemplate;

    @RequestMapping("/hello")
    public String hello() {
        System.out.println("hello world1111111111");
        User user = new User();
        user.setUserId("2222222");
        user.setPassword("bbbbbbb");
        userDao.save(user);
        return "hello world8888888888";
    }

    @GetMapping("/kafka")
    public String sendMessage1() {
        String normalMessage = "hello from wms";
        kafkaTemplate.send("test", normalMessage);
        return "OK";
    }


}
